import { $http } from '../../request/index-api'
import regeneratorRuntime from '../../lib/runtime';
import { login, getUserInfo } from '../../utils/getAddress.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  onShow () {

  },
  async handeluserinfo (e) {
    wx.setStorageSync('token', e.detail);
    const { encryptedData, rawData, iv, signature } = e.detail
    const { code } = await login()
    const params = { encryptedData, rawData, iv, signature, code }
    const res = await $http({ url: '/users/wxlogin', data: params, method: 'POST' })
    const token = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo';
    wx.setStorageSync('token', token);
    const result = await getUserInfo()
    wx.setStorageSync('user', result.userInfo);
    if (res === null) {
      wx.navigateBack({
        delta: 1
      });
    }
  }
})